<html>
<head><meta charset="utf-8"><title>How stable is the verbose version string? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html">How stable is the verbose version string?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216017370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216017370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216017370">(Nov 08 2020 at 17:49)</a>:</h4>
<p>I'm told that currently the only way to reliably ask <code>rustc</code> about the host target triple is to parse the verbose version string. E.g. running this:</p>
<div class="codehilite" data-code-language="plain"><pre><span></span><code>rustc --version --verbose
</code></pre></div>
<p>On my machine the stable compiler prints this:</p>
<div class="codehilite" data-code-language="plain"><pre><span></span><code>rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-pc-windows-msvc
release: 1.47.0
LLVM version: 11.0
</code></pre></div>
<p>How stable is this output? Would the host line ever be removed? Is there an explicit format? Will it always be as simple as splitting on the first <code>: </code> to get key/value pairs after the first line? Is this documented anywhere?</p>



<a name="216025580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216025580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216025580">(Nov 08 2020 at 21:12)</a>:</h4>
<p>It is not considered stable but also doesn't change too often. I would expect that the overall format won't change too much.</p>
<p>What are you using the host triple for? Perhaps there's a better way of getting at that information?</p>



<a name="216026009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216026009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216026009">(Nov 08 2020 at 21:23)</a>:</h4>
<p>Cargo subcommand (edit: third party, to be clear). I need the default target, which is usually the same as the host. Cargo gives you very little information about the environment if you're outside of a build script. I can get it from rustup as well but obviously that requires that rustup is being used.</p>



<a name="216026637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216026637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216026637">(Nov 08 2020 at 21:39)</a>:</h4>
<p>Huh, if I'm understand this is seems that <a href="https://github.com/rust-lang/cargo/blob/f12d72e11b8643b4851a50325d77af962931fe98/src/cargo/util/rustc.rs#L51">Cargo itself</a> uses <code>-Vv</code> for this purpose. It extracts the "host: " and "release: " fields. I'm not particularly comfortable doing this myself but I can't find another way.</p>



<a name="216027867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216027867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216027867">(Nov 08 2020 at 22:09)</a>:</h4>
<p>Hmm... perhaps <code>rustc --print</code> should have an option that exposes these fields in a way that has stronger guarantees?</p>



<a name="216028008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216028008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216028008">(Nov 08 2020 at 22:12)</a>:</h4>
<p>I would suggest making a PR against Cargo that exposes this information to cargo subcommands, probably as an environment variable</p>



<a name="216028018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216028018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216028018">(Nov 08 2020 at 22:12)</a>:</h4>
<p>That said I would not object o a --print for the host triple, that seems reasonable</p>



<a name="216028027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216028027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216028027">(Nov 08 2020 at 22:13)</a>:</h4>
<p>cargo does set <code>HOST</code> for build scripts, at least</p>



<a name="216028155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216028155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216028155">(Nov 08 2020 at 22:16)</a>:</h4>
<p>Not for anything else. All subcommands get is a <code>CARGO</code> variable that points to the cargo binary. Useful but not much to work with.</p>



<a name="216028171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20stable%20is%20the%20verbose%20version%20string%3F/near/216028171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20stable.20is.20the.20verbose.20version.20string.3F.html#216028171">(Nov 08 2020 at 22:17)</a>:</h4>
<p>But yeah, this is ultimately a Cargo issue.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>